package com.neusoft.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.neusoft.domain.DeliveryAddress;
import com.neusoft.service.DeliveryAddressService;
import com.neusoft.service.impl.DeliveryAddressServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/DeliveryAddressController")
public class DeliveryAddressController {

    @Autowired
    DeliveryAddressService service ;

    @GetMapping("/listDeliveryAddressByUserId")
    public List<DeliveryAddress> listDeliveryAddressByUserId(String userId) {
        return service.listDeliveryAddressByUserId(userId);
    }

    @PostMapping("/saveDeliveryAddress")
    public Integer saveDeliveryAddress(@RequestBody DeliveryAddress deliveryAddress) {
        return service.saveDeliveryAddress(deliveryAddress);
    }

    @DeleteMapping("/removeDeliveryAddress/{daId}")
    public Integer removeDeliveryAddress(@PathVariable Integer daId) {
        return service.removeDeliveryAddress(daId);
    }

    @GetMapping("/getDeliveryAddressById/{daId}")
    public DeliveryAddress getDeliveryAddressById(@PathVariable Integer daId) {
        return service.getDeliveryAddressById(daId);
    }

    @PutMapping("/updateDeliveryAddress")
    public Integer updateDeliveryAddress(@RequestBody DeliveryAddress deliveryAddress) {
        return service.updateDeliveryAddress(deliveryAddress);
    }
}
